package com.furongji.common.config;

import com.furongji.common.interceptor.UserInfoInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

// gateway底层用的是WebFlux响应式编程，所以这个配置只作用于包含mvc的微服务
@Configuration
@ConditionalOnClass(DispatcherServlet.class)
public class MvcConfiguration implements WebMvcConfigurer {
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new UserInfoInterceptor())
                .excludePathPatterns(
                        "/api/orders/notify",
                        "/api/orders/pay/**");
    }
}
